<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/8/13
 * Time: 17:11
 */

namespace app\api\validate;


class IDCollection extends BaseValidate
{
    protected  $rule = [
       'ids'=> 'require|checkIDs'
    ];

    protected  $message = [
      'ids'=>'传入id必须是以逗号分隔的正整数字符串'
    ];

    /**
     * ids验证规则
     * @param $value
     * @return bool
     */
    protected  function checkIDs($value){
        $values = explode(',',$value);
        if (empty($values)){
            return false;
        }
        foreach ($values as $id){
                if (!$this->isPositiveInt($id)){
                     return false;
                }
        }
        return true;
    }
}